#!/bin/bash
#####################################################################
# LNMP is a bash script for the installation of Nginx + PHP + MySQL.#
# Author        Hehl <1181554113@qq.com>                            #
# Blog          Http://www.cnblogs.com/ddif                         #
#####################################################################

preinstall_php
install_libmcrypt

#Install PHP
install_php(){
echo "/usr/local/lib" >> /etc/ld.so.conf && ldconfig
pushd $src_dir
if [ -z $php_version_select -o $php_version_select -eq 1 ];then
	php_install_dir_use="${php_install_dir}/${php_version[1]}"
	if [ ! -f ${php_gz[1]} ];then
		down_url -O $php_gz[1] ${php_url[1]}
		if [ $? -ne 0 ];then
			echo -e "Download ${php_url[1]} Failed!!"
			exit
		fi
	fi
	unzip_notice
	tar xzf ${php_gz[1]}
	cd ${php_version[1]}
else
	php_install_dir_use="${php_install_dir}/${php_version[2]}"
	if [ ! -f ${php_gz[2]} ];then
		down_url -O $php_gz[2] ${php_url[2]}
		if [ $? -ne 0 ];then
			echo -e "Download ${php_url[2]} Failed!!"
			exit
		fi
	fi
	unzip_notice
	tar xzf ${php_gz[2]}
	cd ${php_version[2]}
fi
config_php
add_php_boot
popd
copy_php_fpm
}
install_php
